define(["servers"], function (servers) {
    return  Backbone.Model.extend({
        defaults: function () {
            return {
                chartDefault:{
                    chartType:"line",
                    titles:[
                        {"id":"pv","name":"展示次数"},{"id":"click","name":"点击次数"},
                        {"id":"cr","name":"点击率"},{"id":"fr","name":"平均点击价格"},{"id":"cpm","name":"平均展示价格"},{"id":"cost","name":"消费"}
                    ]
                },
                chartQueue:{count:2,list:["pv"]}//count最大值2
            };
        },
        mappingListData:{
            "appName":"appname","platformName":"platformname","adFormatName":"adformatname",
            "pv": "pv","click": "click","income": "income","cr": "cr","cpm": "cpm","fr": "fr","description": "description"
        },
        getReportData:function (param) {
            var self = this;
            servers.report.list(param,function(res){
                var conversion={total:{},list:{}};
                if(res.success && res.data.list.length > 0) {
                    conversion.list = $.map(res.data.list, function (item) {
                        var temp=$.ExtCommon.getMappingJson(item, self.mappingListData);
                        temp.pv=$.ExtCommon.isCheckEmpty(temp.pv)?0:temp.pv;
                        temp.click=$.ExtCommon.isCheckEmpty(temp.click)?0:temp.click;
                        temp.cost=$.ExtCommon.isCheckEmpty(temp.cost)?0:temp.cost.toFixed(2);
                        temp.cr=$.ExtCommon.isCheckEmpty(temp.cr)?0:temp.cr.toFixed(2);
                        temp.cpm=$.ExtCommon.isCheckEmpty(temp.cpm)?0:temp.cpm.toFixed(2);
                        temp.cpc=$.ExtCommon.isCheckEmpty(temp.cpc)?0:temp.cpc.toFixed(2);
                        return temp;
                    });
                    conversion.total=$.ExtCommon.getMappingJson(res.data.total, self.mappingListData);
                }
                res.dataConversion=conversion;
                self.set({dataReport:{req:param,res:res}});
                self.trigger('bind:ReportData');
            });
        }
    });
});